// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   CMTableModel.java

package com.boci.common.ui.control;

import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;

public class CMTableModel extends DefaultTableModel
{

    public CMTableModel()
    {
        m_ColumnNames = new ArrayList();
        m_Rows = new ArrayList();
        intEditableCol = -1;
    }

    public void setEditableCol(int pColIndex)
    {
        intEditableCol = pColIndex;
    }

    public void setData(Object data[][])
    {
        m_Rows.clear();
        for(int i = 0; i < data.length; i++)
        {
            ArrayList colData = new ArrayList();
            for(int j = 0; j < data[i].length; j++)
                colData.add(data[i][j]);

            m_Rows.add(colData);
        }

    }

    public void setColumnName(String columnNames[])
    {
        m_ColumnNames.clear();
        for(int i = 0; i < columnNames.length; i++)
            m_ColumnNames.add(columnNames[i]);

    }

    public int getColumnCount()
    {
        if(m_ColumnNames == null)
            return 0;
        else
            return m_ColumnNames.size();
    }

    public int getRowCount()
    {
        if(m_Rows == null)
            return 0;
        else
            return m_Rows.size();
    }

    public String getColumnName(int col)
    {
        if(m_ColumnNames == null)
            return null;
        else
            return (String)m_ColumnNames.get(col);
    }

    public Object getValueAt(int row, int col)
    {
        ArrayList colData = (ArrayList)m_Rows.get(row);
        return colData.get(col);
    }

    public Class getColumnClass(int c)
    {
        return getValueAt(0, c).getClass();
    }

    public boolean isCellEditable(int row, int col)
    {
        return col == intEditableCol;
    }

    public void setValueAt(Object value, int row, int col)
    {
        ArrayList colData = (ArrayList)m_Rows.get(row);
        colData.set(col, value);
        fireTableCellUpdated(row, col);
    }

    ArrayList m_ColumnNames;
    ArrayList m_Rows;
    int intEditableCol;
}
